#include "list.h"

void Print(const HJR::list<int>& lt)
{
	HJR::list<int>::const_iterator it = lt.begin();
	while (it != lt.end())
	{
		// (*it) += 1;
		std::cout << *it << " ";
		++it;
	}
	std::cout << std::endl;
}

void test_list1()
{
	HJR::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	HJR::list<int>::iterator it = lt.begin();

	while (it != lt.end())
	{
		(*it) += 1;
		std::cout << *it << " ";
		++it;
	}
	std::cout << std::endl;

	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	Print(lt);
}

struct A
{
	A(int a1 = 0, int a2 = 0)
		:_a1(a1)
		, _a2(a2)
	{
	}

	int _a1;
	int _a2;
};

void test_list2()
{
	HJR::list<A> lt;
	lt.push_back(A(1, 1));
	lt.push_back(A(2, 2));
	lt.push_back(A(3, 3));
	lt.push_back(A(4, 4));

	HJR::list<A>::iterator it = lt.begin();
	while (it != lt.end())
	{
		//std::cout << (*it)._a1 << " " << (*it)._a2 << std::endl;
		std::cout << it->_a1 << " " << it->_a2 << std::endl;

		++it;
	}
	std::cout << std::endl;
}

void test_list3()
{
	HJR::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);
	lt.push_front(5);
	lt.push_front(6);
	lt.push_front(7);
	lt.push_front(8);
	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	lt.pop_front();
	lt.pop_back();

	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	lt.clear();
	lt.push_back(10);
	lt.push_back(20);
	lt.push_back(30);
	lt.push_back(40);
	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	std::cout << lt.size() << std::endl;
}

void test_list4()
{
	HJR::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	HJR::list<int> lt1(lt);
	for (auto e : lt1)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	HJR::list<int> lt2;
	lt2.push_back(10);
	lt2.push_back(20);
	lt2.push_back(30);
	lt2.push_back(40);

	for (auto e : lt2)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	lt1 = lt2;

	for (auto e : lt1)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;
}

void test_list5()
{
	HJR::list<int> lt;
	lt.push_back(1);
	lt.push_back(2);
	lt.push_back(3);
	lt.push_back(4);

	for (auto e : lt)
	{
		std::cout << e << " ";
	}
	std::cout << std::endl;

	HJR::list<int>::reverse_iterator rit = lt.rbegin();
	while (rit != lt.rend())
	{
		std::cout << *rit << " ";
		++rit;
	}
	std::cout << std::endl;
}

int main()
{
	//test_list1();
	//test_list2();
	//test_list3();
	//test_list4();
	//test_list5();

	return 0;
}